//
//  HPUserAccount.swift
//  MyWeibo
//
//  Created by apple on 16/4/11.
//  Copyright © 2016年 Apengpeng. All rights reserved.
//

import UIKit

class HPUserAccount: NSObject {
    
    // 给需要保存的用户信息添加属性,, 其他的不需要保存
    var access_token: String?
    var expires_in: NSTimeInterval = 0 {
        didSet {
            // 计算过期日期
            expires_Date = NSDate(timeIntervalSinceNow: expires_in)
        }
    }
    
    // 增加过期日期, (当前的日期 + 过期的时间)
    var expires_Date: NSDate?
    
    var uid: String?
    var name: String?
    // 用户头像url
    var avatar_large: String?
    
    init(dict: [String:AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    //字典转模型
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {  }
    
    // 重写description 方法
    override var description: String {
        let keys = ["access_token","avatar_large","name","uid","expires_in","expires_date"]
        let dict = self.dictionaryWithValuesForKeys(keys)
        return dict.description
    }
}
